<template>
    <RouterView />

    <!-- 全局的loading -->
    <Loading />

    <!-- 全局的消息弹框 -->
    <Toast />
</template>

<script>
import { usePhotoSwipe } from '@/lib/photoSwipe'
import Loading from '@/components/business/loading/Main.vue'
import Toast from '@/components/business/toast/Main.vue'
import { useToastStore } from '@/stores/toast'
import { copyText } from '@/lib/util'

window.CESIUM_BASE_URL = 'https://cdn.bootcdn.net/ajax/libs/cesium/1.125.0/'
export default {
    components: {
        Loading,
        Toast
    },
    setup () {
        const toastStore = useToastStore()
        usePhotoSwipe()

        window.copyCode = (e) => {
            const codeStr = e.target.parentNode.querySelector('code').innerText
            if (codeStr && copyText(codeStr)) {
                toastStore.info('代码已复制到粘贴板！')
            }
        }
    }
}
</script>

<style lang="scss">
@use './style/reset.scss';
@use './style/iconfont.scss';
@use './style/layout.scss';
@use './style/article.scss';
@use './style/github.markdown.scss';
</style>
